package sicnu.cs.aps.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sicnu.cs.aps.common.enums.ActivityAuditEnum;
import sicnu.cs.aps.common.enums.ActivitySignEnum;
import sicnu.cs.aps.domain.dto.TeamPlanDto;
import sicnu.cs.aps.domain.entity.ActivityPlan;
import sicnu.cs.aps.domain.vo.TimeEventVo;
import sicnu.cs.aps.mapper.ActivityPlanMapper;
import sicnu.cs.aps.service.IActivityPlanService;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author chengke
 * @version 1.0
 * @className ActivityPlanServiceImpl
 * @description 填写活动策划实现类
 * @date 2022/5/27 16:50
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanMapper, ActivityPlan> implements IActivityPlanService {

    private final ActivityPlanMapper activityPlanMapper;

    /**
     * 通过小队id 查询队伍策划中的相关信息
     *
     * @param teamId 队伍id
     * @return 策划中的三条时间事件
     */
    @Override
    public List<TimeEventVo> listTeamPlanTimeLine(Long teamId) {
        ActivityPlan activityPlan = activityPlanMapper.getPlanInfoByTeamId(teamId);
        if (activityPlan == null) {
            return null;
        }
        List<TimeEventVo> timeEventVos = new ArrayList<>();
        timeEventVos.add(TimeEventVo.builder()
                .opTime(activityPlan.getPlanEndTime())
//                .operatorName("")
//                .operatorId()
                .opEvent(ActivitySignEnum.ACTIVITY_WAIT_FOR_FEEDBACK)
                .opDesc("预计活动结束时间(策划方案)")
                .operatorName("无")
                .build());
        timeEventVos.add(TimeEventVo.builder()
                .opTime(activityPlan.getPlanStartTime())
//                .operatorName("")
//                .operatorId(()
                .opEvent(ActivitySignEnum.ACTIVITY_ON)
                .opDesc("预计活动开始时间(策划方案)")
                .operatorName("无")
                .build());
        return timeEventVos;
    }

    /**
     * 通过小队id查询队伍策划信息
     *
     * @param teamId 队伍id
     * @return 队伍的策划
     */
    @Override
    public ActivityPlan getPlanByTeamId(Long teamId) {
        return activityPlanMapper.getPlanInfoByTeamId(teamId);
    }

    /**
     * 通过teamId查询策划列表
     *
     * @param teamIds 队伍id
     * @return 队伍策划
     */
    @Override
    public List<TeamPlanDto> listPlanInTeams(List<Long> teamIds) {
        return activityPlanMapper.listPlanDtoByTeamId(teamIds);
    }

//    /**
//     * 查询所有的策划信息
//     *
//     * @return 策划信息
//     */
//    @Override
//    public List<TeamPlanDto> listAllPlanInTeams() {
//        return activityPlanMapper.listPlanDto();
//    }
}